package com.mt.channel.service.model;

import java.util.List;
import java.util.Map;

import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

import com.github.pagehelper.PageHelper;
import com.mt.channel.entity.ChannelAccountLogEntity;
import com.mt.channel.mapper.ChannelAccountLogEntityMapper;
import com.mt.common.PagerInfo;
import com.mt.common.ServiceResult;

@Component
public class ChannelAccountLogServiceModel {
    private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(ChannelAccountLogServiceModel.class);

    @Autowired
    private ChannelAccountLogEntityMapper channelAccountLogEntityMapper;

    public ServiceResult<List<ChannelAccountLogEntity>> selectList(Map<String, Object> params, PagerInfo<?> pagerInfo) {
        Assert.notNull(this.channelAccountLogEntityMapper, "Property 'channelAccountLogEntityMapper' is required.");
        ServiceResult<List<ChannelAccountLogEntity>> result = new ServiceResult<List<ChannelAccountLogEntity>>();
        try {
            if (pagerInfo != null) {
                PageHelper.startPage(pagerInfo.getPageIndex(), pagerInfo.getPageSize());
            }
            result.setResult(this.channelAccountLogEntityMapper.selectList(params));
        } catch (Exception e) {
            result.setSuccess(false);
            result.setMessage("Unknown error!");
            LOGGER.error("[ChannelAccountLogServiceModel][selectList]：query selectList occur exception", e);
        }
        return result;
    }

    public ServiceResult<ChannelAccountLogEntity> selectInfo(Map<String, Object> params) {
        Assert.notNull(this.channelAccountLogEntityMapper, "Property 'channelAccountLogEntityMapper' is required.");
        ServiceResult<ChannelAccountLogEntity> result = new ServiceResult<ChannelAccountLogEntity>();
        try {
            result.setResult(this.channelAccountLogEntityMapper.selectByPrimaryKey(params));
        } catch (Exception e) {
            result.setSuccess(false);
            result.setMessage("Unknown error!");
            LOGGER.error("[ChannelAccountLogServiceModel][selectInfo]：query selectInfo occur exception", e);
        }
        return result;
    }

    public ServiceResult<ChannelAccountLogEntity> selectAmounts(Map<String, Object> params) {
        Assert.notNull(this.channelAccountLogEntityMapper, "Property 'channelAccountLogEntityMapper' is required.");
        ServiceResult<ChannelAccountLogEntity> result = new ServiceResult<ChannelAccountLogEntity>();
        try {
            result.setResult(this.channelAccountLogEntityMapper.selectAmounts(params));
        } catch (Exception e) {
            result.setSuccess(false);
            result.setMessage("Unknown error!");
            LOGGER.error("[ChannelAccountLogServiceModel][selectAmounts]：query selectAmounts occur exception", e);
        }
        return result;
    }
}